<?php
class DashboardController extends Controller{

    /**
     * manage the dashboard
     */

    public function init() {

      if (user()->getUserProperty('username') == '')
        $this->redirect(BACKEND_SITE_URL);
    }

    public function actionIndex() {
        //register cs
        //$cs = cs();
        //$cs->registerScriptFile(BACKEND_SITE_URL . 'js/lib/jquery.sparkline.min.js');
        //$cs->registerScriptFile('https://www.google.com/jsapi');
        $this->layout = 'dashboard';

        $this->render('index');
    }
    
    public function actionUserManage(){
      $seeking = array(1 => 'Man seeking Women',2 =>'Man seeking Man',3 => 'Woman seeking Man',4 => 'Woman seeking women');
      $this->layout = 'dashboard';      
      //$seeking = new Constant::getSeekingArray();
      $user_id = app()->getRequest()->getParam('delete');
      if($user_id>0 && is_numeric($user_id)){
        if(r()->isPostRequest){
         
          User::model()->deleteUserId($user_id);
          
          $this->redirect(BACKEND_SITE_URL.'dashboard/usermanage');
        }else{
          $this->render('user_delete',array('user_id'=>$user_id));
        }
      }else{
        $user_id = app()->getRequest()->getParam('update');
        if($user_id>0 && is_numeric($user_id)){
          $mProfile = new mProfile();
          $profile = $mProfile->getProfileWithPhotosPrimary(user()->getUserProperty('user_id'));
          $cs = cs();
          $cs->registerScriptFile(BACKEND_SITE_URL . 'js/forms.js',CClientScript::POS_END);
          $this->render('user_update',array('profile'=>$profile));
        }else{
          $rs_user = User::model()->getUserToViewedNoLimit();
          $this->render('user_manage',array('rs_user'=>$rs_user,'seeking'=>$seeking));
        }
      }
      //$this->render('user_manage',array('rs_user'=>$rs_user,'seeking'=>$seeking));
    }
    
}